<div class="container-fluid" style="margin: 0px 15px 0px 15px;">
<ol class="breadcrumb">
  <li><a href="<?php echo base_url('/index.php/inicio');?>">Início</a></li>
  <li><a href="<?php echo base_url('index.php/ausentes/consulta');?>">Ausência</a></li>
  <li class="active">Novo</li>
</ol>
		<fieldset>
		<legend>Cadastro Férias Usuário</legend>

		<form class="form-horizontal" role="form" id="form" method="POST">
		<input type="hidden" name="id" value="<?php echo $ausente->id; ?>" />
				<div class="form-group">
				<label for="inputEmail3" class="col-sm-2 control-label">Login</label>
				<div class="col-sm-2">
					<?php 
						$data = array('disabled'=>'disabled','name'=> 'login','id'=> 'login','value'=> @$ausente->login,'placeholder'=> 'Login','class'=> 'form-control input-sm');
						echo form_input($data);
					?>
				</div>
				</div>
				<div class="form-group">
				<label for="inputPassword3" class="col-sm-2 control-label">Nome Completo</label>
				<div class="col-sm-4">
					<?php 
						$data = array('disabled'=>'disabled','name'=> 'nome','id'=> 'nome','value'=> @$ausente->nome_completo,'placeholder'=> 'Nome Completo','class'=> 'form-control input-sm');
						echo form_input($data);
					?>
				</div>
				</div>
				<div class="form-group">
				<label for="inputPassword3" class="col-sm-2 control-label">Data Início</label>
				<div class="col-sm-1">
				  <input type="text" class="form-control input-sm" name="inicio" id="inicio" placeholder="Data Início">
				</div>
				</div>
				<div class="form-group">
				<label for="inputPassword3" class="col-sm-2 control-label">Data Fim</label>
				<div class="col-sm-1">
				  <input type="text" class="form-control input-sm" name="fim" id="fim" placeholder="Data Fim">
				</div>
				</div>
				<div class="form-group">
				<label for="inputPassword3" class="col-sm-2 control-label">Tipo</label>
				<div class="col-sm-2">
					<?php 
						$tipo = array('A'=>'AFASTAMENTO','F'=>'FÉRIAS','L'=>'LICENÇA','O'=>'OUTROS',''=>'');
						echo form_dropdown('tipo',$tipo,'','class="form-control input-sm"');
						
					?>
				</div>
				
				</div>
							
				<div class="form-group">
				<label for="inputPassword3" class="col-sm-2 control-label">Observação</label>
				<div class="col-sm-4">
					<?php 
						$data = array('name'=> 'observacao','id'=> 'observacao','placeholder'=> 'Observação','class'=> 'form-control input-sm', 'value'=> '','rows'=>'3' );
						echo form_textarea($data);
					?>
				</div>
				</div>
				<!--
				<?php
				echo form_fieldset('Atende quais processos?');
				?>

				<div class="form-group">
				<label for="inputPassword3" class="col-sm-2 control-label">PROCESSO ADMINISTRATIVO</label>
				<div class="col-sm-4">
					<div class="make-switch switch-mini" data-on-label="<i class='icon-ok icon-white'></i>" data-off-label="<i class='icon-remove'></i>">
						<input type="checkbox" checked />
					</div>	
				</div>
				</div>
				<div class="form-group">
				<label for="inputPassword3" class="col-sm-2 control-label">PROCESSO JUDICIAL</label>
				<div class="col-sm-4">
					<div class="make-switch switch-mini" data-on-label="<i class='icon-ok icon-white'></i>" data-off-label="<i class='icon-remove'></i>">
						<input type="checkbox" checked />
					</div>	
				</div>
				</div>
				<div class="form-group">
				<label for="inputPassword3" class="col-sm-2 control-label">EXECUÇÃO FISCAL</label>
				<div class="col-sm-4">
					<div class="make-switch switch-mini" data-on-label="<i class='icon-ok icon-white'></i>" data-off-label="<i class='icon-remove'></i>">
						<input type="checkbox" checked />
					</div>	
				</div>
				</div>
				
				<?php
					echo form_fieldset_close(); 
				?>
				-->
				<div class="form-group">
					<div class="col-sm-offset-2 col-sm-10">
					<?php 
						$data = array('name'=>'salvar','type' => 'submit','class' => 'btn btn-primary','content' =>'Salvar');
						echo form_button($data);
						//$data = array('name'=>'cancelar','type' => 'cancel','class' => 'btn btn-default','content' => 'Cancelar');
						//echo form_button($data);
						
					?>
						<a id="cancelar" href="<?php echo base_url('/index.php/usuarios/');?>" class="btn btn-default"></span>Cancelar</a>
					</div>
				</div>

			</form>
			<div id="retorno1"></div>
			</fieldset>

		</div>



	<link href="<?php echo base_url('includes/css/bootstrap-switch.css') ?>" rel="stylesheet">
	<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css">
	<script src="<?php echo base_url('includes/js/bootstrap-switch.js')?>"></script>
	<link href="<?php echo base_url('includes/css/flat-ui-fonts.css') ?>" rel="stylesheet">
	<script language="javascript" type="text/javascript">
			$(document).ready(function(){//Equivalente ao window.onload porem mais rapido
				/*$("#inicio").datepicker({ minDate: -10, maxDate: "+1M +20D", dateFormat: "dd/mm/yy"});
				$("#fim").datepicker({ minDate: -10, maxDate: "+1M +20D", dateFormat: "dd/mm/yy"});*/
				$( "#inicio" ).datepicker({
				  dateFormat: "dd/mm/yy",
				  defaultDate: "+1w",
				  changeMonth: true,
				  numberOfMonths: 3,
				  onClose: function( selectedDate ) {
					$( "#fim" ).datepicker( "option", "minDate", selectedDate );
				  }
				});
				$( "#fim" ).datepicker({
				  dateFormat: "dd/mm/yy",
				  defaultDate: "+1w",
				  changeMonth: true,
				  numberOfMonths: 3,
				  onClose: function( selectedDate ) {
					$( "#inicio" ).datepicker( "option", "maxDate", selectedDate );
				  }
				});
				$("#form").validate({
					rules: {
						inicio: "required",
						fim: "required",
						tipo: "required"
					},
					messages: {
						inicio: "Campo requerido",
						fim: "Campo requerido",
						tipo: "Campo requerido"
					},
					submitHandler: function(form){
						var dados = $('#form').serialize();
						$.ajax({
							type: "POST",
							url: "<?php echo base_url('index.php/ausentes/salvar'); ?>",
							data: dados,
							success: function( data )
							{
								$("html, body").animate({ scrollTop: $(document).height() }, "slow");
								if(data === 'OK'){
									$('#retorno1').html('<div class="alert alert-success" role="alert">CADASTRO EFETUADO COM SUCESSO</div>');
									setTimeout(function() {
										$('#retorno1').html('');
										window.location = "<?php echo base_url('index.php/ausentes/novo'); ?>";
									}, 2000);
								}else{
									$('#retorno1').html(data);
								}
							},
							statusCode: {
								404: function() {
									alertify.error("Pagina nao encontrada");
								}
							}
						});
						return false;
					}
				});
			});
		</script>	
	</body>
</html>